//BlockTest.java
package com.ylaihui.oop10;

class Person{
	private static String nation;
	private int age;
	
	static{
		System.out.println("static block");
		nation = "chinese";
	}
	
	{
		System.out.println("non static block");		
		age = 10;
	}
	
	public static void breath(){
		System.out.println("Person breath...");
	}
}

public class BlockTest {
	public static void main(String[] args) {
		System.out.println("BlockTest");
		
		// 静态代码块随着类的加载而执行,而且只执行一次
		Person.breath();
		Person.breath();
		
		// 非静态代码块每创建一个对象，就执行一次非静态代码块
		Person p1 = new Person();
		Person p2 = new Person();
	}
}
